<template>
	<view class="u-page"> 
		<u--form ref="form" :value="vulcanizationScan" >
			<u-form-item
					label="机台:"
					prop="vulcanizationScan.machcd"
					borderBottom
					ref="item1"
			>
			 <u--input v-model="vulcanizationScan.machcd" border="surround"></u--input>
			</u-form-item>
			  <u-form-item
					label="位置:"
					prop="vulcanizationScan.oriental"
					borderBottom
					ref="item1"
			  >
			  <u-radio-group 
			      v-model="vulcanizationScan.oriental" :customStyle="'text-align: center;'">
				<u-radio label="L" :customStyle="{marginLeft: '30px'}"></u-radio>
				<u-radio label="R" :customStyle="{marginLeft: '50px'}"></u-radio>
			  </u-radio-group>
			  </u-form-item>
			<u-form-item
				prop="vulcanizationScan.tagNo"
				borderBottom 
				label="条码:"
			>
			<u--input v-model="vulcanizationScan.tagNo" border="surround"	></u--input> 
			</u-form-item>
			<u-form-item 
				prop="vulcanizationScan.msg"
				borderBottom
			>
			<u--textarea v-model="vulcanizationScan.msg" placeholder="文本域已被禁用" confirmType ="done" disabled ></u--textarea>
			
			</u-form-item>

		 <view class="vulcaniza-view">
		 	<u-button type="primary" class="vulcaniza-button"  size="large"  @click="confirm" >提交</u-button>
		 <!-- 	<u-button type="primary" class="vulcaniza-button" size="large" @click="clear"  >清除</u-button> -->
		 	       
		 </view>
		</u--form>

 
	</view>

</template>

<script>
export default {
	data() {
		return {
			//扫描记录
			 vulcanizationScan: {
				qrCode: '',
				barCode: '',
				machcd:'',
				oriental: 'L',
				tagNo:'',
				status:'', 
				msg:''
			}, 
			//当前选中项
			selectItem: {},
			//参数
			params: {},
			rules: {
				 
			},
			//加载
			toastParams: {
				type: 'loading',
				title: '正在加载',
				message: "正在加载",
				iconUrl: 'https://cdn.uviewui.com/uview/demo/toast/loading.png',
				duration: 60000,
			},
		}
	},
	onShow() {
		if (!uni.getStorageSync("vuex_token")) {
			this.$u.route('pages/user/login');
		}
		// 每次进来先 移除全局自定义事件监听器
		uni.$off('pdaReceiveScancode')
		uni.$on("pdaReceiveScancode", this.onReceive)
	},
	methods: {  
		//选择行
		chooseItem(item){
			this.selectItem = item;
		},
		onReceive(data) {
 			// this.codeList.push(data.code) 
			console.log("onReceive事件"+data.code) 
			if (data.code.trim().length>20) {
				this.vulcanizationScan.tagNo = data.code 
			} else {
				this.vulcanizationScan.machcd = data.code 
				this.vulcanizationScan.oriental = 'L' 
			}
			 
 		},
		//提交
		confirm(){
			let that = this;
			uni.showModal({
				title: '提示',
				content: '确认提交硫化扫描信息？',
				success: function (res) {
					
					if (res.confirm) {
					    // that.$refs.loadinToast.show({ ...that.toastParams });
						that.$http({url: '/pad/saveScanData', method: 'POST', data: that.vulcanizationScan}).then((stockInRes) => {
							if(stockInRes.code === 200){
								that.vulcanizationScan = []; 
							}
							uni.showToast({ title: stockInRes.msg, icon: 'none' })
						// 	that.$refs.loadinToast.hide();
						 });
					}
				}
			});
		},
		clear(){
				this.vulcanizationScan.machcd = ''
				this.vulcanizationScan.machcd = ''
				this.vulcanizationScan.msg = ''
				
 		}
	}
}
</script>

<style lang="scss">
// .content{
// 	padding: 0 30rpx 0 30rpx;
// 	display: flex;
// 	align-items: flex-end;
// 	font-size: 30rpx;
// 	color: #515151;

// }
.vulcaniza-view{
    display: flex;
	text-align: center;
	align-items: flex-end;
	flex-wrap: nowrap;
}

.vulcaniza-button{
   width: 80px;
}
</style>
